package com.levy.contronller.javaWeb.threadConcurrence.countDownLatch;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by levy on 2019/4/8.
 */
public class CountDownLatchDemo {

    public static void main(String[] args) {
        ExecutorService executor = Executors.newCachedThreadPool();

        CountDownLatch latch = new CountDownLatch(4);

        Worker w1 = new Worker(latch, "张三");
        Worker w2 = new Worker(latch, "李四");
        Worker w3 = new Worker(latch, "王二");
        Worker w4 = new Worker(latch, "赵五");

        Boss boss = new Boss(latch);

        executor.execute(w1);
        executor.execute(w2);
        executor.execute(w3);
        executor.execute(w4);
        executor.execute(boss);

        executor.shutdown();
    }


}
